package com.instpower.things.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.instpower.things.helper.BitUtil;
import lombok.Data;

import java.util.List;

/**
 * @ClassName Battery
 * @Author: hellmash@gmail.com
 * @Date: 2020/3/15
 * @Version: 1.0.0
 * @Description: 电池信息
 *
 * {"slot_num":"1",
 *  "run_flag": "0",
 *  "slot_flag":"0",
 *  "battery_sn":"alfjfjfjflfd",
 *  "full_flag":"1",
 *  "full_per":"80"
 * }
 * {"slot_num":"1",
 *  "run_flag": "0", --0:空闲:非零:不空闲
 *  "slot_flag":"0", --0:正常;1:与主板通信异常;2:与电池通信异常;3:允许借出标志;4:当前充电标志
 *  "battery_sn":"AFYK7Y4A03300003",
 *  "full_flag":"1",
 *  "full_per":"80"
 * },
 *
 */
@Data
public class Battery {

    /**
     * 机柜编号
     */
    @JsonProperty(value = "cabinet_sn")
    private String cabinetSn;

    /**
     * 槽位编号
     */
    @JsonProperty(value = "slot_num")
    private int slotNum;

    /**
     * 运行标志
     */
    @JsonProperty(value = "run_flag")
    private int runFlag;

    /**
     * 槽位状态标志
     */
    @JsonProperty(value = "slot_flag")
    private int slotFlag;

    /**
     * 电池编号
     */
    @JsonProperty(value = "battery_sn")
    private String sn;

    /**
     * 充电次数
     */
    @JsonProperty(value = "cycle_count")
    private int cycleCount;

    /**
     * 电量百分比
     */
    @JsonProperty(value = "full_per")
    private int fullPer;

    /**
     * 充电宝状态标志
     */
    @JsonProperty(value = "full_flag")
    private int fullFlag;

    /**
     * 充电宝状态标志
     */
    @JsonProperty(value = "full_flag_info")
    private String fullFlagInfo;
    /**
     * 最后一次更新时间
     */
    @JsonProperty(value = "last_update_time")
    private String lastUpdateTime;

    public void setFullFlag(int fullFlag) {
        this.fullFlag = fullFlag;
        this.setFullFlagInfo(BitUtil.formatStrng(fullFlag));
    }
}
